﻿using DeepEarth.Map.Core;
using System.Collections.Generic;
using System;
using System.Linq;
using DeepEarth.Map.Core.Tiling;

namespace DeepEarth.Map.TileSources
{
	public class MDSTileSourceFactory : BaseTileSourceFactory
	{
		public readonly static MapMode StreetMap = new MapMode("mds", "streetMap", "StreetMap", "Street Map", 0, false, true, true);
		private static readonly MapMode[] _availableModes = new[] { StreetMap };
		public override IList<MapMode> AvailableModes { get { return _availableModes; } }

		private readonly MDSMapTileSource StreetMapTileSource = new MDSMapTileSource();

		public static bool IsValidMode(MapMode mode)
		{
			return _availableModes.Contains(mode);
		}

		public static void ValidateMode(MapMode mode)
		{
			if (!IsValidMode(mode))
				throw new ArgumentOutOfRangeException(String.Format("Map mode '{0}:{1}' is not valid for the MDS provider",
																	mode.ProviderKey,
																	mode.Identifier));
		}

		public override BaseTileSource CreateTileSource(MapMode mode)
		{
			mode = ValidateAndCoerceMapMode(mode);
			return StreetMapTileSource;
		}

	}
}
